<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="/permission" prefix="pe" %>
<html>
<head>
    <jsp:include page="../../include/head.jsp"/>
</head>
<body>
<jsp:include page="../../include/model.jsp"/>
<div class="main_body" style="margin:0px;">
    <div class="span9 page_message">
        <section id="contents">
            <ul class="tab-nav nav">
                <li class="current"><a href="">团单（${groupOrder.groupName}）付款列表<span class="arrow fa fa-sort-up"></span></a></li>
            </ul>
            <p class="normal_tips" style="display:none"><b class="fa fa-info-circle"></b></p>

            <div class="table-bar">
                <div class="fl">
                    <div class="tools">

                    </div>
                    <div class="search-form fr cf">
                        <form id="saveForm" name="saveForm" action="${BasePath}/order/groupOrderPay/save?${PublicParams}" method="post">
                            <input type="hidden" name="idGroupOrder" value="${groupOrder.id}"/>
                            新增付款：
                            日期&nbsp;<input type="text" class="txt100" name="payDate" id="payDate" value="" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'payDate\')}',readOnly:'false'})"/>
                            金额&nbsp;<input type="text" class="txt100" name="amount" id="amount" value=""/>
                            备注&nbsp;<input type="text" name="comments" value="" maxlength="30"/>
                            <input type="button" onclick="checkForm()" value="保存" class="btn btn-success " style="margin-top: -10px"/>
                        </form>
                    </div>
                </div>
            </div>
            <div class="data-table">
                <div class="table-striped">
                    <table cellspacing="1">
                        <thead>
                        <tr>
                            <th class="row-selected row-selected">
                                <input type="checkbox" id="checkAll" class="check-all regular-checkbox"><label for="checkAll"></label>
                            </th>
                            <th>ID</th>
                            <th>日期</th>
                            <th>金额</th>
                            <th>备注</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${list}" var="bean">
                            <tr>
                                <td><input type="checkbox" id="check_${bean.id}" name="ids[]" value="${bean.id}" class="ids regular-checkbox"><label for="check_${bean.id}"></label></td>
                                <td class="id">${bean.id}</td>
                                <td><script>formatDate(${bean.payDate});</script></td>
                                <td>${bean.amount}</td>
                                <td>${bean.comments}</td>
                                <td><input type="button" class="btn-small btn-danger" value="删除" onclick="toDel(${bean.id})"/> </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                    <div class="page" id="pager"></div>
                </div>
            </div>
        </section>
    </div>
</div>
<jsp:include page="../../include/bottom.jsp"/>
<script type="application/javascript">
    function checkForm() {
        var payDate = $("#payDate").val();
        if (payDate == "") {
            layer.msg('请选择付款日期！', {icon: 5});
            return false;
        }
        var amount = $("#amount").val();
        if (amount == "") {
            layer.msg('请输入金额！', {icon: 5});
            return false;
        }
        $('#saveForm').ajaxSubmit(function (data) {
            if (data.errno == 1) {
                layer.alert(data.errdesc);
            } else {
                layer.msg("操作成功！");
                window.location=window.location.href;
            }
        });
    }
    function toDel(id) {
        if(confirm('你确定要删除吗？')){
            $.getJSON("${BasePath}/order/groupOrderPay/del?id=" + id, function (data) {
                if (data.errno == 0) {
                    layer.msg("操作成功！");
                    window.location.reload();
                } else {
                    layer.msg(data.errdesc, {icon: 5});
                }
            });
        }
    }
</script>
</body>
</html>